<template>
		<div class="icons">
			<swiper :options="swiperOption">
				<swiper-slide v-for="(page, index) of pages" :key="index">
				<div class="icon" v-for="item of page" :key="item.id">
					<img class="icon-img" :src='item.imgUrl'>
					<p class="icon-desc">{{item.desc}}</p>
				</div>
				</swiper-slide>
			</swiper>
		</div>
	</div>
</template>

<script>
export default{
	name:'HomeIcons',
	props:{
		list: Array
	},
	data (){
		return {
			swiperOption:{
				autoplay:false
			}
		}
	},
	 computed: {
    	pages () {
      		const pages = []
      		this.list.forEach((item, index) => {
      			
        		const page = Math.floor(index / 8)
        		if (!pages[page]) {
          		pages[page] = []
       	 }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>

<style lang="stylus" scoped>
	.icons
		width:100%
		.icon
			float:left
			width:25%
			height:0
			padding-bottom:25%
			overflow:hidden
			.icon-img
				padding-top:0.15rem
				width:60%
				margin:0 auto
				display:block
			.icon-desc
				padding-top:0.1rem
				text-align:center
				color:#333	
					
					
				
</style>